<template>
  <!--返款申请列表,查询已支付开票税金-->
  <div>
    <a-card :bordered="false">
      <f-search-form :more="false" @searchHandler="searchHandler" :showSearchBtn="false">
        <f-search-form-item label="供货方" :showAll="false" name="supplierId" type="select" :data="api.supplier.list" valueKey="supplierId" label-key="supplierName" @change="supplierChange"/>
      </f-search-form>
      <f-table ref="table" rowKey="invoiceDetailsId" :columns="columns" handler="paidInvoicePaymentPageListHandler" :multiple="false" :operator="operator" :autoLoad="false" :params="queryParam" :api="api.payment">
     <span slot="action" slot-scope="text, record">
          <template>
            <a @click="$refs.rid.showDrawer(record)">申请返款</a>
          </template>
        </span>
      </f-table>
      <refund-form ref="rid" @closeInvoiceList="closeInvoiceList"></refund-form>
    </a-card>
  </div>
</template>
<script>

  import api from './../js/api'
  import RefundForm from './refund_form'

  export default {
    name: 'RefundInvoiceList',
    components: { RefundForm },
    data() {
      let me = this
      //操作按钮
      let operator = []
      return {
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {
          supplierId: ''
        },
        // 表头
        columns: [
          {
            title: '#',
            width: '60',
            align: 'center',
            customRender: (text, record, index) => index + 1
          },
          {
            title: '税金单号',
            align: 'center',
            dataIndex: 'paymentNo'
          },
          {
            title: '开票单位',
            align: 'center',
            dataIndex: 'invoiceunitName'
          },
          {
            title: '开票金额',
            align: 'center',
            dataIndex: 'invoiceAmount'
          },
          {
            title: '开票日期',
            align: 'center',
            dataIndex: 'amountDate'
          },
          {
            title: '应返金额',
            align: 'center',
            dataIndex: 'supplierRetable'
          },
          {
            title: '已返金额',
            align: 'center',
            dataIndex: 'supplierReal'
          },
          {
            title: '未返金额',
            align: 'center',
            dataIndex: 'noSupplierRetable'
          },
          {
            title: '税金',
            align: 'center',
            dataIndex: 'amount'
          },
          {
            title: '支付人',
            align: 'center',
            dataIndex: 'payUserName'
          },
          {
            title: '支付日期',
            align: 'center',
            dataIndex: 'payDate'
          },
          {
            title: '操作',
            align: 'center',
            scopedSlots: { customRender: 'action' }
          }
        ],
        operator: operator
      }
    },
    created() {
    },
    methods: {
      supplierChange(value) {
        this.queryParam.supplierId = value
        this.$refs.table.refresh(false)
      },
      closeInvoiceList() {
        this.$emit('closeDrawer')
      },
    }
  }
</script>
